using Admin2025.Application.Dtos;
using Admin2025.Application.Services;
using Microsoft.AspNetCore.Mvc;

namespace Admin2025.Api.Controllers;

[ApiController]
[Route("api/[controller]")]
public class PermissionController : ControllerBase
{
    private readonly IAppPermissionService _service;
    public PermissionController(IAppPermissionService service)
    {
        _service = service;
    }

     [HttpGet]
    public async Task<IActionResult> GetAll()
    {
        var result = await _service.GetAllPermissionAsync();
        return Ok(result);
    }

    [HttpPost]
    public async Task<IActionResult> Create([FromBody] CreatePermissionDto dto)
    {
        var result = await _service.CreatePermissionAsync(dto);
        return Ok(result);
    }
    [HttpDelete("{id}")]
    public async Task<IActionResult> Delete(Guid id)
    {
        var result = await _service.DeletePermissionAsync(id);
        return Ok(result);
    }
    [HttpPut("{id}")]
    public async Task<IActionResult> Update(Guid id,[FromBody] UpdatePermissionDto dto)
    {
        var result = await _service.UpdatePermissionAsync(id, dto);
        return Ok(result);
    }
    [HttpPost("{id}/enable")]
    public async Task<IActionResult> Enable(Guid id)
    {
        var result = await _service.EnablePermission(id);
        return Ok(result);
    }
    [HttpPost("{id}/disable")]
    public async Task<IActionResult> Disable(Guid id)
    {
        var result = await _service.DisablePermission(id);
        return Ok(result);
    }
   
}